﻿using System.Threading;
using System.Threading.Tasks;

namespace Fast.Extensions.DatabaseAccessor.EntityFrameworkCore
{
    /// <summary>
    /// 写仓储接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IWritableRepository<TEntity> : IRootWritableRepository<TEntity, DefaultDbContextLocator>,
        IInsertableRepository<TEntity>,
        IUpdateableRepository<TEntity>,
        IDeletableRepository<TEntity>
        where TEntity : class, IRootEntity, new()

    {

    }

    /// <summary>
    /// 写仓储接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IRootWritableRepository<TEntity, TDbContextLocator> : IRootWritableRepository<TEntity>
        , IRootInsertableRepository<TEntity, TDbContextLocator>
        , IRootUpdateableRepository<TEntity, TDbContextLocator>
        , IRootDeletableRepository<TEntity, TDbContextLocator>
        , IRootRepositoryBase
        where TEntity : class, IRootEntity, new()
        where TDbContextLocator : class, IDbContextLocator
    {

    }

    /// <summary>
    /// 写仓储接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IRootWritableRepository<TEntity>
        : IRootInsertableRepository<TEntity>
        , IRootUpdateableRepository<TEntity>
        , IRootDeletableRepository<TEntity>
        , IRootRepositoryBase
        where TEntity : class, IRootEntity, new()
    {
        /// <summary>
        /// 保存更改操作
        /// </summary>
        /// <returns></returns>
        int SaveChanges();
        /// <summary>
        /// 保存更改操作（异步）
        /// </summary>
        /// <returns></returns>
        Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
    }
}
